package org.method;

public class MethodDemo1 {
    public static void main(String[] args) {
        int[] arr = {10,20,30,50};
        printArray(arr);
    }
    public static void printArray(int[] arr){
        if(arr==null) {
            return;
        }
        System.out.print("[");
        for (int i = 0; i < arr.length; i++) {
           /* if(i==arr.length-1){
                System.out.print(arr[i]);
            }else{
                System.out.print(arr[i]+",");
            }*/
            System.out.println(i == arr.length-1 ? arr[i]:arr[i]+",");
        }
        System.out.print("]");
    }
}
